/**
 * 开始 入口场景
 */
class StartScreen extends egret.DisplayObjectContainer {
    /** 加载背景图 */
    private bg_png: egret.Bitmap = Main.createBitmapByName("home_bg_png");
    /** 进入按钮 */
    private start_btn: egret.Bitmap = Main.createBitmapByName("start_btn_png");
    /** 加载bgm */
    public static bgm;
    public static mviaBgm;

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {
        this.addChild(this.bg_png);
        /** 创建开始按钮 */
        this.addChild(this.start_btn);
        /** 设置开始按钮 */
        this.setStartBtn();
        StartScreen.bgm = RES.getRes("bgm_mp3");
    }
    /** 开始按钮设置 */
    private setStartBtn(): void {
        Main.anchorCenter(this.start_btn);
        this.start_btn.x = this.stage.stageWidth * .5;
        this.start_btn.y = this.stage.stageHeight * .8 - 50;
        this.start_btn.touchEnabled = true;
        this.start_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.startBtnHandler, this);
    }
    /** 开始按钮事件处理 */
    private startBtnHandler(evt: egret.TouchEvent): void {
        console.log("this's start_btn");
        StartScreen.mviaBgm = StartScreen.bgm.play();
        this.dispatchEvent(new egret.Event("next"));
    }
}